package com.geo.geotool.service;

import org.locationtech.jts.geom.CoordinateSequence;
import org.locationtech.jts.geom.CoordinateSequenceFilter;

public class RemoveZFilter implements CoordinateSequenceFilter{
    private boolean done = false;

    @Override
    public void filter(CoordinateSequence seq, int i) {
        if(seq.hasZ()) {
            System.out.println("Removing Z value from coordinate " + seq.getZ(i));
            seq.setOrdinate(i, 2, Double.NaN);
            if (i == seq.size()) {
                done = true;
            }
        }
    }

    @Override
    public boolean isDone() {
        return done;
    }

    @Override
    public boolean isGeometryChanged() {
        return true;
    }
}
